import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;


// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pageSize,
    keywords: queryParams.keywords,
    category: queryParams.category, //培训分类 id
    shiftId: queryParams.shiftId, // 培训班组 id
    trainMode: queryParams.trainMode, //培训方式 id
    examMode: queryParams.examMode, //考试方式 id
    trainLevel: queryParams.trainLevel, //培训级别 id
    trainPlace: queryParams.trainPlace, //培训地点 id
    department: queryParams.department, //培训部门 id
    releaseStatus: queryParams.releaseStatus, // 发布情况 0-待发布 1-已发布
    startTime: queryParams.startTime,
    endTime: queryParams.endTime
  }
  return request({
    url: '/getTrainingtasksList',
    method: 'post',
    data: data
  })
}



// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getTrainingtasksData',
    method: 'post',
    data: data
  })
}


// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delTrainingtasks',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultipleTrainingtasks(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleCurriculum',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getTrainingrecordComboBox',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
  const data = {
    projectContent: {
      theid,
      enable
    }
  }
  return request({
    url: '/changeEnableTrainingtasks',
    method: 'post',
    data: data
  })
}

// 考试统计 
export function getExamStatistics(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getExamStatistics',
    method: 'post',
    data: data
  })
}
// 培训班组下拉

// 培训班组人员
export function getCrew(queryParams) {
  const data = {
    theid: queryParams.theid,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pageSize,
  }
  return request({
    url: '/getPersonnelListTrainRecord',
    method: 'post',
    data: data
  })
}
// export function getCrew(queryParams) {
//   const data = {
//     ascriptionId: store.state.userInfo.ascriptionId,
//     currentPage: queryParams.currentPage,
//     pagesize: queryParams.pageSize,
//     trainTaskId: queryParams.trainTaskId
//   }
//   return request({
//     url: '/getTrainingrecordList',
//     method: 'post',
//     data: data
//   })
// }

// 培训班组
export function getTeam(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getShiftList',
    method: 'post',
    data: data
  })
}

// 查看试卷
export function getPaper(queryParams) {
  const data = {
    trainTaskId: queryParams.theid,
    personnelType: queryParams.personnelType,
    personnelId: queryParams.personnelId,
  }
  return request({
    url: '/getExamRecordTestPaper',
    method: 'post',
    data: data
  })
}

// 审核  
export function getAuditask(val) {
  const data = {
    projectContent: {
      theids: val.theids, //id ( 多个 id 时, 格式为：3,6,8,55 )
      trainingtaskId: val.trainingtaskId, //培训任务 id
      reviewerId: val.reviewerId, //审核人 id
      reviewer: val.reviewer, //审核人
      reviewStatus: val.reviewStatus, //审核结果 1-合格 2-不合格
    }
  }
  return request({
    url: '/toExamineTrainingrecord',
    method: 'post',
    data: data
  })
}